package model.entity.role;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "PageFunction")
public class PageFunction {

	private int functionId;
	private String shortName;
	private String description;
	private List<PageTask> pageTasks = new ArrayList<PageTask>(0);

	public PageFunction() {
	}

	public PageFunction(String shortName) {
		this.shortName = shortName;
	}

	public PageFunction(String shortName, String description,
			List<PageTask> pageTasks) {
		this.shortName = shortName;
		this.description = description;
		this.pageTasks = pageTasks;
	}

	@Id
	@GeneratedValue(generator = "PageFunction_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "PageFunction_ID_Gen", sequenceName = "PageFunction_SEQ_ID")
	@Column(name = "FunctionID", unique = true, nullable = false)
	public int getFunctionId() {
		return this.functionId;
	}

	public void setFunctionId(int functionId) {
		this.functionId = functionId;
	}

	@Column(name = "ShortName", nullable = false)
	public String getShortName() {
		return this.shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	@Column(name = "Description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "pageFunction")
	public List<PageTask> getPageTasks() {
		return this.pageTasks;
	}

	public void setPageTasks(List<PageTask> pageTasks) {
		this.pageTasks = pageTasks;
	}

}
